using System;
using System.Text;
namespace ServiceStack.Logging
{
	public class StringBuilderLog : ILog
	{
		private const string DEBUG = "DEBUG: ";
		private const string ERROR = "ERROR: ";
		private const string FATAL = "FATAL: ";
		private const string INFO = "INFO: ";
		private const string WARN = "WARN: ";
		private readonly StringBuilder logs;
		public bool IsDebugEnabled
		{
			get
			{
				return true;
			}
		}
		public StringBuilderLog(string type, StringBuilder logs)
		{
			this.logs = logs;
		}
		public StringBuilderLog(Type type, StringBuilder logs)
		{
			this.logs = logs;
		}
		private void Log(object message, Exception exception)
		{
			string text = (message == null) ? string.Empty : message.ToString();
			if (exception != null)
			{
				text = text + ", Exception: " + exception.get_Message();
			}
			StringBuilder stringBuilder = this.logs;
			lock (stringBuilder)
			{
				this.logs.AppendLine(text);
			}
		}
		private void LogFormat(object message, params object[] args)
		{
			string text = (message == null) ? string.Empty : message.ToString();
			StringBuilder stringBuilder = this.logs;
			lock (stringBuilder)
			{
				this.logs.AppendFormat(text, args);
				this.logs.AppendLine();
			}
		}
		private void Log(object message)
		{
			string text = (message == null) ? string.Empty : message.ToString();
			StringBuilder stringBuilder = this.logs;
			lock (stringBuilder)
			{
				this.logs.AppendLine(text);
			}
		}
		public void Debug(object message, Exception exception)
		{
			this.Log("DEBUG: " + message, exception);
		}
		public void Debug(object message)
		{
			this.Log("DEBUG: " + message);
		}
		public void DebugFormat(string format, params object[] args)
		{
			this.LogFormat("DEBUG: " + format, args);
		}
		public void Error(object message, Exception exception)
		{
			this.Log("ERROR: " + message, exception);
		}
		public void Error(object message)
		{
			this.Log("ERROR: " + message);
		}
		public void ErrorFormat(string format, params object[] args)
		{
			this.LogFormat("ERROR: " + format, args);
		}
		public void Fatal(object message, Exception exception)
		{
			this.Log("FATAL: " + message, exception);
		}
		public void Fatal(object message)
		{
			this.Log("FATAL: " + message);
		}
		public void FatalFormat(string format, params object[] args)
		{
			this.LogFormat("FATAL: " + format, args);
		}
		public void Info(object message, Exception exception)
		{
			this.Log("INFO: " + message, exception);
		}
		public void Info(object message)
		{
			this.Log("INFO: " + message);
		}
		public void InfoFormat(string format, params object[] args)
		{
			this.LogFormat("INFO: " + format, args);
		}
		public void Warn(object message, Exception exception)
		{
			this.Log("WARN: " + message, exception);
		}
		public void Warn(object message)
		{
			this.Log("WARN: " + message);
		}
		public void WarnFormat(string format, params object[] args)
		{
			this.LogFormat("WARN: " + format, args);
		}
	}
}
